package com.example.venue_reservation_service.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.venue_reservation_service.service.VeSessionService;
import com.example.venue_reservation_service.domain.VeSession;
import com.example.venue_reservation_service.mapper.VeSessionMapper;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.UUID;

/**
* @author 31586
* &#064;description  针对表【venue_session】的数据库操作Service实现
* &#064;createDate  2025-06-17 15:36:33
 */
@Service
public class VeSessionServiceImpl extends ServiceImpl<VeSessionMapper, VeSession>
    implements VeSessionService {

    @Resource
    private VeSessionMapper sessionMapper;

    @Override
    public VeSession createSession(Integer userId, String userIp) {
        VeSession session = new VeSession();
        session.setUserId(userId);
        session.setUserIp(userIp);
        session.setStartTime(LocalDateTime.now());
        session.setSessionToken(UUID.randomUUID().toString());
        session.setTitle("New Chat");
        sessionMapper.insert(session);
        return session;
    }

    @Override
    public VeSession getByToken(String token) {
        return sessionMapper.selectBySessionToken(token);
    }
}




